{extend name="layout/layout" /}

{block name="pagecss"}
<style>
	#container{
		width: 650px;
		height: 300px;
	}
</style>
<link href="__STATIC__/admin/pages/css/article.css" rel="stylesheet" type="text/css" />
<link href="__STATIC__/plugins/umeditor/umeditor.min.css" rel="stylesheet" type="text/css" />
{/block}

{block name="content"}
<div class="row">
	<div class="col-xs-12">
		<div class="box box-success">
			<div class="box-header with-border">
				<h3 class="box-title">发布文章</h3>
				<div class="box-tools">
					<!--<button class="btn bg-navy btn-sm" data-toggle="tooltip" title="" data-original-title="Back" onclick="history.go(-1);">
                        <i class="fa fa-reply"></i> 返回
                    </button>-->
				</div>
			</div>
			<div class="box-body">
				<form id="modal_new_role" class="form-horizontal form validation-form" method="post" enctype="multipart/form-data">
					{:token()}
					<div class="form-body">
						<div class="form-group">
							<lable class="col-lg-2 control-label"><span class="required"> * </span>文章标题：</lable>
							<div class="col-md-8">
								<input type="text" class="form-control input-large" name="input_title" maxlength="40" value="{$row.title}" placeholder="请输入文章标题">
							</div>
						</div>

						<div class="form-group">
							<lable class="col-lg-2 control-label"><span class="required"> * </span>文章图片：</lable>
							<div class=" col-md-8" id="btn-uploader">
								<button type="button" class="btn btn-default pull-left add_btn margin-bottom-20" id="sgimg_add" >上传主图</button>
								<span class="form-control-static pull-left zhushi margin-left">
								用于首页和列表展示，建议尺寸357像素×357像素，大小不超过500kb </span>
							</div>
						</div>

						<div class="form-group">
							<div class=" col-lg-2 col-xs-3"></div>
							<div class="col-md-8">
								<div id="btn-uploader" class="row">
									<div class="col-md-3" style="">
										<img  class="img-responsive img" name="img" src="{$row.iconUrl}" />
									</div>
								</div>
							</div>
						</div>

						<div class="form-group">
							<lable class="col-lg-2 control-label"><span class="required"> * </span>文章排序：</lable>
							<div class="col-md-8">

								<input type="text" class="form-control input-small" name="orderNo" maxlength="5" value="{$row.orderNo}" placeholder="请输入排序">
							</div>
						</div>

						<div class="form-group">
							<lable class="col-lg-2 control-label">
								<span class="required"> * </span>文章详情：</lable>
							<div class="col-md-8">
								<!-- 加载编辑器的容器 -->
								<script id="container" name="detail" type="text/plain"></script>
								<div id="pro_txt" class="hidden">{$row.detail}</div>
								<div id="btn-uploader1">
									<a id="pickfiles1" href="javascript:void 0;"></a>
								</div>
								<a id="pickfilesforarticleRadio" href="javascript:;"></a>
							</div>
						</div>

						<input type="hidden" name="id" value="{$row.id}">
						<hr />

						<div class="form-actions">
							<div class="row">
								<div class="col-md-12">
									<div class="form-group">
										<label class="col-md-3 control-label"></label>
										<div class="col-md-9">
											<button type="button" class="btn btn-primary" id="modal_sure_new">
												保存 <i class="fa fa-floppy-o"></i>
											</button>
											<button type="button" class="btn btn-default" onclick="history.go(-1);">
												返回 <i class="fa fa-mail-forward"></i>
											</button>
											<div class="help-block " style="color:red"></div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
{/block}

{block name="pagescript"}
<script src="__STATIC__/admin/js/include.js" type="text/javascript"></script>
<script src="__STATIC__/admin/pages/js/article.js" type="text/javascript"></script>
<!-- 配置文件 -->
<script type="text/javascript" src="__STATIC__/plugins/umeditor/template.min.js"></script>
<script type="text/javascript" src="__STATIC__/plugins/umeditor/umeditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="__STATIC__/plugins/umeditor/umeditor.min.js"></script>
<script src="__STATIC__/admin/js/qiniu/plupload.full.min.js" type="text/javascript"></script>
<script src="__STATIC__/admin/js/qiniu/qiniu.js" type="text/javascript"></script>
<script src="__STATIC__/admin/js/qiniu/custom.js" type="text/javascript"></script>
<script src="__STATIC__/admin/js/qiniu/qiniuConfig.js" type="text/javascript"></script>

<!-- 实例化编辑器 -->
<script type="text/javascript">
    var index_list = "{:url('admin/article/indexApi')}";  //查询文章列表
    var token_url = "{:url('admin/Image/token')}";   //获取七牛token地址
    var save_url = "{:url('admin/article/save')}";   //保存提交地址
    var index_url = "{:url('admin/article/index')}";  //查询文章列表
    var record_url = "{:url('admin/Image/record')}";   //图片上传总表记录
    var del_img_url = "{:url('admin/Image/delete')}";   ////图片上传总表删除地址

    window.UMEDITOR_CONFIG.toolbar = [
        // 加入一个 test
        'source | fontfamily fontsize | justifyleft justifycenter justifyright | bold italic underline strikethrough  forecolor  | insertorderedlist insertunorderedlist | image'
        ];
    UM.registerUI('image',
        function(name) {
            var me = this;
            var $btn = $.eduibutton({
                icon: name,
                click: function() {
                    document.getElementById("pickfiles1").click();
                },
                title: '上传图片'
            });

            /*this.addListener('selectionchange',function(){
                //切换为不可编辑时，把自己变灰
                var state = this.queryCommandState(name);
                $btn.edui().disabled(state == -1).active(state == 1)
            });*/
            return $btn;
        }
    );
    UM.registerUI('video',
        function(name) {
            var me = this;
            var $btn = $.eduibutton({
                icon: name,
                click: function() {
                    document.getElementById("pickfilesforarticleRadio").click();
                },
                title: '上传视频'
            });

            /*this.addListener('selectionchange',function(){
                //切换为不可编辑时，把自己变灰
                var state = this.queryCommandState(name);
                $btn.edui().disabled(state == -1).active(state == 1)
            });*/
            return $btn;
        }
    );
    var um = UM.getEditor('container');
    $(document).ready(function() {
        var pro_value = $("#pro_txt").html();
        um.ready(function() { //编辑器初始化完成再赋值
            um.setContent(pro_value); //赋值给UEditor
        });
    });
</script>
{/block}